﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.IO;
using FyndSharp.Data;
using System.Web.Configuration;

namespace Fynd.Hermes.Web
{
    public class Global : System.Web.HttpApplication
    {
        public static readonly string HttpSessionKeyUserId = "__SESSION_USER_ID__";
        public static readonly string HttpContextKeyUser = "__CONTEXT_USER__";

        public static string UploadRootPath
        {
            get
            {
                return WebConfigurationManager.AppSettings["UploadRootPath"];
            }
        }

        protected void Application_Start(object sender, EventArgs e)
        {
            log4net.Config.XmlConfigurator.Configure(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(Global));
            if (log.IsInfoEnabled)
            {
                log.Info("Application Started.");
            }

            AdoSessionManager.AddConnectionString("hermes"
                , DatabaseType.Sqlite
                , WebConfigurationManager.ConnectionStrings["hermes"].ConnectionString);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(typeof(Global));
            if (log.IsInfoEnabled)
            {
                log.Info("Application Ended.");
            }
        }
    }
}